<title>用户列表</title>
</head>
<style>
    th, td {
        border: bisque solid 1px;
    }

    img {
        width: 100px;
        height: 100px;
        border-radius: 100%;
    }
</style>

<body>
<h2>用户列表</h2>
<form method="get" th:action="@{/user/list}">
    <input name="key" placeholder="昵称/电话 进行查询">
    <input type="submit" value="查询">
</form>
<table style="width: 85%;border: bisque solid 1px;">
    <tr>
        <th>序号</th>
        <th>昵称</th>
        <th>头像</th>
        <th>性别</th>
        <th>邮箱</th>
        <th>电话</th>
        <th>状态</th>
        <th colspan="3">操作</th>
    </tr>
    <tr th:each="user,iterStat : ${pageBean.result}">
        <td th:text="${iterStat.count}"></td>
        <td th:text="${user.nickname}"></td>
        <td>
            <img th:src="${user.avatar}">
        </td>
        <td th:text="${user.gender}?男:女"></td>
        <td th:text="${user.email}"></td>
        <td th:text="${user.phone}"></td>
        <td>
            <span th:if="${user.state==0}" th:text="已删除"></span>
            <span th:if="${user.state==1}" th:text="正常"></span>
            <span th:if="${user.state==2}" th:text="功能受限"></span>
            <span th:if="${user.state==3}" th:text="活跃"></span>
        </td>
        <td>
            <a th:href="@{/user/details(id=${user.id})}">详情</a>
        </td>
        <td>
            <a th:href="@{/user/openUpdate(id=${user.id})}">修改</a>
        </td>
        <td>
            <a href="javascript:void(0)" th:onclick="'deleteUser('+${user.id}+')'">删除</a>
        </td>
    </tr>

    <script type="text/javascript">
        function deleteUser(id) {
            if (confirm("确认删除当前用户吗？")) {
                document.location.href = "/user/delete?id=" + id;
            }
        }
    </script>

    <tr>
        <td colspan="10">
            <span th:if="${pageBean.pages>=1}" th:each="index:${#numbers.sequence(1,pageBean.pages)}">
                <a th:href="@{?pageNum=}+${index}" th:text="${index}"></a>
            </span>
        </td>
    </tr>
</table>
</body>

</html>